﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Organizer
{
    public partial class FormChangePass : Form
    {
        public delegate bool ChangePassDelegate(string newPass);
        ChangePassDelegate ChangePass;

        public FormChangePass()
        {
            InitializeComponent();
        }

        public void ShowDialog(ChangePassDelegate ChangePass)
        {
            this.ChangePass = ChangePass;
            ShowDialog();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            string pass1 = txbPass1.Text.Trim();
            string pass2 = txbPass2.Text.Trim();
            if (pass1 != pass2)
            {
                MessageBox.Show("Пароли не совпадают");
                return;
            }

            if (!ChangePass(pass1)) return;

            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
